## 
## DAWG
## 
## file: DAWG/tests/CMakeLists.txt
## date: 14 october 2014
## author: Francis Girard
## 


cmake_minimum_required (VERSION 2.6)
project (dawg_tests)


##
##
##
cmake_policy(SET CMP0015 OLD)


##
## The version number.
##
set (dawg_VERSION_MAJOR 0)
set (dawg_VERSION_MINOR 1)

##
## Release / Debug
## Always "Release" for the tests when publishing
## because that is how it ought to work.
##
SET(CMAKE_BUILD_TYPE "Release")

##
## Bin / Lib output paths
##
set(LIBRARY_OUTPUT_PATH ./lib/${CMAKE_BUILD_TYPE})
set(EXECUTABLE_OUTPUT_PATH ./bin/${CMAKE_BUILD_TYPE})

##
## Try to find the CppUnit package
##
## If found, it defines :
##
## CPPUNIT_INCLUDE_DIRS
## CPPUNIT_LIBRARIES
##
## Otherwise, if not found, compilation
## is halted right away and we exit
##
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}")
FIND_PACKAGE(CppUnit)

IF (CPPUNIT_FOUND)
	MESSAGE(STATUS "CppUnit found.\n\nCPPUNIT_INCLUDE_DIRS: ${CPPUNIT_INCLUDE_DIRS}\n")
	MESSAGE(STATUS "CPPUNIT_ROOT_DIR: ${CPPUNIT_ROOT_DIR}")
	MESSAGE(STATUS "CPPUNIT_LIBRARY_RELEASE: ${CPPUNIT_LIBRARY_RELEASE}")
	MESSAGE(STATUS "CPPUNIT_INCLUDE_DIRS: ${CPPUNIT_INCLUDE_DIRS}")
	MESSAGE(STATUS "CPPUNIT_LIBRARIES: ${CPPUNIT_LIBRARIES}")
ELSE (CPPUNIT_FOUND)
	MESSAGE(FATAL_ERROR "\n>>>!!! FATAL ERROR \n>>>!!! Could not find CppUnit package.\n>>>!!! Makefile generation will stop incomplete.\n\nIn order to execute the unit tests, you first have to install cppunit.\nOn an Ubuntu system it may be as simple as doing this:\nsudo apt-get install libcppunit-dev\nsudo apt-get install libcppunit-doc\n")
ENDIF(CPPUNIT_FOUND)

################################################################################
##                                                                            ##
## DAWG specific precompilation directives                                    ##
##                                                                            ##
################################################################################

IF(CMAKE_SYSTEM MATCHES "Windows*")
add_definitions(-DWIN32)
ENDIF(CMAKE_SYSTEM MATCHES "Windows*")

IF(CMAKE_BUILD_TYPE MATCHES "Debug")
add_definitions(-DDEBUG)
ELSE(CMAKE_BUILD_TYPE MATCHES "Debug")
add_definitions(-DNDEBUG)
ENDIF(CMAKE_BUILD_TYPE MATCHES "Debug")

##
## When building DLL library on windows
##

IF(CMAKE_SYSTEM MATCHES "Windows*")
add_definitions(-DDO_DAWG_EXPORT_DLL)
ENDIF(CMAKE_SYSTEM MATCHES "Windows*")


################################################################################
##                                                                            ##
## CPP UNIT include and link directories                                      ##
##                                                                            ##
################################################################################


include_directories(${CPPUNIT_INCLUDE_DIRS})
link_directories (${CPPUNIT_LIBRARIES})


################################################################################
##                                                                            ##
## Dawg Tests                                                                 ##
##                                                                            ##
################################################################################


include_directories(../src)

add_executable (testdawg
                main.cpp
                TestCase_DawgArr.cpp
                TestCase_DawgUniqueNodeSet.cpp
                TestCase_DawgSha1.cpp
                TestCase_DawgGnode.cpp
                ../src/sha1.c 
                ../src/dawg_rbt.c
                ../src/dawg_arr_str.c
		../src/dawg_arr_void_ptr.c
		../src/dawg_arr_unsigned_char.c
		../src/dawg_arr_node.c
                ../src/dawg_unique_node_set.c
		../src/dawg_gnode.c)

target_link_libraries (testdawg cppunit) 


